Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

batch Read&Write api #2

Open
izouxv opened this issue May 28, 2024 · 0 comments
Open

batch Read&Write api #2

izouxv opened this issue May 28, 2024 · 0 comments

Comments

@izouxv
Copy link

izouxv commented May 28, 2024

hi
go-journal is very good
I have two suggestions

1: the disk function maybe need a error return

orignal Disk interface

type Disk interface { 
	Read(a uint64) (Block, error) 
	ReadTo(a uint64, b Block) error 
	Write(a uint64, v Block) error 
	Size() (uint64, error) 
	Barrier() error
	Close() error
}

the Disk can be mem fs, file fs, or network fs (ths fs implement the Disk interface with smb client)

2: batch read & write to resuse IO

the io is very intensive when WRITE a big file
writing a data, it will make 4 write operates

  • 1 write log block(journal data)
  • 2 update block0(disk addrs)
  • 3 update block1(start pos),
  • 4 write data back.

if writing a big data consecutively, Batch interfaces can be used to reduce IO in the setp 1 and 4
if reading a big data consecutiveley, It's the same with writing
the interface about like this.

type DiskWriteBatch interface {
	WriteBatch(startPos uint64, blocks []Block) error
}
type DiskReadBatch interface {
	ReadBatch(startPos uint64, blockLen int) ([]Block, error)
}

could you add a batch WRITE api, or give me some advice
thank you

@izouxv izouxv changed the title batch WRITE api batch Read&Write api May 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant