Skip to content

Add cursor to File#868

Open
vinc wants to merge 3 commits into
trunkfrom
feature/file-cursor
Open

Add cursor to File#868
vinc wants to merge 3 commits into
trunkfrom
feature/file-cursor

Conversation

@vinc

@vinc vinc commented Jul 14, 2026

Copy link
Copy Markdown
Owner

No description provided.

@vinc

vinc commented Jul 14, 2026

Copy link
Copy Markdown
Owner Author

Before with a cold cache:

> time pkg i spell
Retrieving "/var/pkg/spell"
Retrieving "/lib/spell/english.dict.z"
Extracting "/lib/spell/english.dict"
Executed "pkg i spell" in 12.253962s

Before with a warm cache

> time pkg i spell
Retrieving "/var/pkg/spell"
Retrieving "/lib/spell/english.dict.z"
Extracting "/lib/spell/english.dict"
Executed "pkg i spell" in 7.564066s

After with a cold cache:

> time pkg i spell
Retrieving "/var/pkg/spell"
Retrieving "/lib/spell/english.dict.z"
Extracting "/lib/spell/english.dict"
Executed "pkg i spell" in 9.260961s

After with a warm cache:

> time pkg i spell
Retrieving "/var/pkg/spell"
Retrieving "/lib/spell/english.dict.z"
Extracting "/lib/spell/english.dict"
Executed "pkg i spell" in 7.591063s

So this optimization is useful with a cold cache but not by much.

@vinc

vinc commented Jul 14, 2026

Copy link
Copy Markdown
Owner Author

I tried another optimization that didn't provide any measurable gains due to the cache:

diff --git a/src/sys/fs/file.rs b/src/sys/fs/file.rs
index 1238d4f..64d4e57 100644
--- a/src/sys/fs/file.rs
+++ b/src/sys/fs/file.rs
@@ -150,13 +150,13 @@ impl FileIO for File {
                 }
                 pos += 1;
             }
-            match block.next() {
-                Some(next_block) => {
-                    addr = next_block.addr();
-                    self.cursor_addr = addr;
+            match block.next_addr() {
+                0 => return Ok(bytes),
+                next_addr => {
+                    addr = next_addr;
+                    self.cursor_addr = next_addr;
                     self.cursor_pos = pos;
                 }
-                None => return Ok(bytes),
             }
         }
     }

@vinc
vinc marked this pull request as ready for review July 14, 2026 11:00
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

Successfully merging this pull request may close these issues.

1 participant