Skip to content

Cache driver acceleration configuration - #127

Open
Gnarus-G wants to merge 2 commits into
mainfrom
perf/cache-driver-config
Open

Cache driver acceleration configuration#127
Gnarus-G wants to merge 2 commits into
mainfrom
perf/cache-driver-config

Conversation

@Gnarus-G

@Gnarus-G Gnarus-G commented Aug 2, 2026

Copy link
Copy Markdown
Owner

Summary

  • parse module parameters and derive DPI, rotation, and curve constants only when configuration changes
  • publish prepared configuration to the input path with a seqlock
  • move synthetic rotation event insertion to a cold, out-of-line helper
  • bump the driver package version to 0.5.10

Performance

  • standalone fixed-point benchmark: 1.2x-1.46x faster prepared acceleration path before counting eliminated string parsing
  • rebuilt maccel_events: 10,744 bytes down to 611 bytes, with the 7,579-byte acceleration routine outlined

Verification

  • make build
  • make test
  • cargo test --all
  • Kimi K3 adversarial diff review: no findings

Runtime hardware verification was intentionally omitted because it requires loading the kernel module.

Summary by CodeRabbit

  • New Features

    • Improved acceleration processing with more consistent sensitivity, scaling, rotation, and curve behavior.
    • Configuration changes are applied more reliably after parameter updates and during driver startup.
    • Improved handling of synthetic rotation input events on newer Linux kernels.
  • Bug Fixes

    • Preserved acceleration boundary and cap behavior while improving runtime consistency.
  • Chores

    • Updated the package version from 0.5.9 to 0.5.10.

@vercel

vercel Bot commented Aug 2, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
maccel Ready Ready Preview Aug 2, 2026 2:54am

@coderabbitai

coderabbitai Bot commented Aug 2, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 33034e7e-b20c-4064-9a10-d67a5aa4851e

📥 Commits

Reviewing files that changed from the base of the PR and between 71342ef and 7b6e130.

📒 Files selected for processing (3)
  • driver/Makefile
  • driver/fixedptc.h
  • driver/tests/accel.test.c

📝 Walkthrough

Walkthrough

The driver now prepares acceleration and curve parameters before runtime use. A seqlock cache refreshes these values after parameter updates. Rotation event insertion uses a dedicated helper. The package version changes to 0.5.10.

Changes

Acceleration pipeline

Layer / File(s) Summary
Curve argument preparation
driver/accel/*.h
Linear, natural, and synchronous curves now prepare derived values before sensitivity evaluation.
Prepared acceleration execution
driver/accel.h, driver/fixedptc.h, driver/tests/accel.test.c, driver/Makefile
Acceleration preparation stores DPI, rotation, and curve values. Runtime acceleration and tests consume the prepared arguments.
Cached configuration lifecycle
driver/accel_k.h, driver/params.h, driver/maccel.c
Parameter updates refresh a seqlock-protected cache. Initialization refreshes the cache before device setup. Acceleration reads prepared arguments.
Rotation event injection
driver/input_handler.h
A helper inserts synthetic relative events when capacity and values permit.

Package release metadata

Layer / File(s) Summary
Package version update
PKGBUILD
The package version changes from 0.5.9 to 0.5.10.

Estimated code review effort: 4 (Complex) | ~45 minutes

Sequence Diagram(s)

sequenceDiagram
  participant ParameterCallbacks
  participant refresh_cached_args
  participant SeqlockCache
  participant collect_args
  participant f_accelerate_prepared
  ParameterCallbacks->>refresh_cached_args: refresh after successful parameter update
  refresh_cached_args->>SeqlockCache: publish prepared_accel_args
  collect_args->>SeqlockCache: read prepared_accel_args with retry protection
  SeqlockCache-->>collect_args: return stable prepared arguments
  f_accelerate_prepared->>collect_args: use cached prepared arguments
Loading

Poem

I’m a rabbit with settings to cache,
Preparing each curve in a flash.
Rotation events hop into line,
While seqlocks keep values in time.
And the package blooms: point five ten!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 16.67% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the pull request's primary change: caching the driver's acceleration configuration.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch perf/cache-driver-config

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (2)
driver/input_handler.h (1)

70-109: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Fix asymmetric event-count bookkeeping and misleading debug log.

The X-insertion block (lines 83-94) advances syn_pos, end, and count together on success. The Y-insertion block (lines 96-105) advances only count, not syn_pos or end. In the current function this has no live effect, because neither variable is read after the Y block. But it leaves the two blocks inconsistent. A future change that reorders the blocks, adds a third insertion, or reuses end/syn_pos after the Y block will silently use stale values and desync memmove ranges from count.

Also, in both blocks, dbg(...) sits outside if (syn_pos). When syn_pos is NULL (no SYN_REPORT found), the function logs a successful injection message even though nothing was inserted. This produces a misleading debug trace exactly when a user is troubleshooting rotation behavior with a debug build.

♻️ Proposed fix for symmetry and log accuracy
   if (injected_x && synthetic_x_val != NONE_EVENT_VALUE && count < max) {
     if (syn_pos) {
       memmove(syn_pos + 1, syn_pos, (end - syn_pos) * sizeof(*syn_pos));
       syn_pos->type = EV_REL;
       syn_pos->code = REL_X;
       syn_pos->value = synthetic_x_val;
       syn_pos++;
       end++;
       count++;
+      dbg("rotation: injected synthetic REL_X = %d", synthetic_x_val);
     }
-    dbg("rotation: injected synthetic REL_X = %d", synthetic_x_val);
   }

   if (injected_y && synthetic_y_val != NONE_EVENT_VALUE && count < max) {
     if (syn_pos) {
       memmove(syn_pos + 1, syn_pos, (end - syn_pos) * sizeof(*syn_pos));
       syn_pos->type = EV_REL;
       syn_pos->code = REL_Y;
       syn_pos->value = synthetic_y_val;
+      syn_pos++;
+      end++;
       count++;
+      dbg("rotation: injected synthetic REL_Y = %d", synthetic_y_val);
     }
-    dbg("rotation: injected synthetic REL_Y = %d", synthetic_y_val);
   }
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@driver/input_handler.h` around lines 70 - 109, Make the Y-insertion block in
inject_rotation_events mirror the successful X-insertion bookkeeping by
advancing syn_pos and end along with count after memmove. Move each rotation
debug message inside its corresponding if (syn_pos) block so it is emitted only
when the synthetic event was actually inserted.
driver/accel.h (1)

50-51: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Add static to the new file-scope constants.

NORMALIZED_DPI and DEG_TO_RAD_FACTOR are defined without static, unlike every other symbol in this header, which uses static inline. Without static, these objects have external linkage. If this header is ever included from more than one translation unit that is linked together, the linker reports duplicate symbols.

Add static to match the file's existing internal-linkage convention.

As per coding guidelines, "Adhere to existing project conventions, mimic surrounding code style and patterns."

🔧 Proposed fix
-const fpt NORMALIZED_DPI = fpt_fromint(1000);
-const fpt DEG_TO_RAD_FACTOR = fpt_xdiv(FIXEDPT_PI, fpt_rconst(180));
+static const fpt NORMALIZED_DPI = fpt_fromint(1000);
+static const fpt DEG_TO_RAD_FACTOR = fpt_xdiv(FIXEDPT_PI, fpt_rconst(180));
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@driver/accel.h` around lines 50 - 51, Update the file-scope constants
NORMALIZED_DPI and DEG_TO_RAD_FACTOR to use static, matching the header’s
existing internal-linkage convention and preventing duplicate symbols across
translation units.

Source: Coding guidelines

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@driver/accel.h`:
- Around line 50-51: Update the file-scope constants NORMALIZED_DPI and
DEG_TO_RAD_FACTOR to use static, matching the header’s existing internal-linkage
convention and preventing duplicate symbols across translation units.

In `@driver/input_handler.h`:
- Around line 70-109: Make the Y-insertion block in inject_rotation_events
mirror the successful X-insertion bookkeeping by advancing syn_pos and end along
with count after memmove. Move each rotation debug message inside its
corresponding if (syn_pos) block so it is emitted only when the synthetic event
was actually inserted.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 059b4a6e-f4d6-4142-be4e-570263d9b012

📥 Commits

Reviewing files that changed from the base of the PR and between e398002 and 71342ef.

📒 Files selected for processing (9)
  • PKGBUILD
  • driver/accel.h
  • driver/accel/linear.h
  • driver/accel/natural.h
  • driver/accel/synchronous.h
  • driver/accel_k.h
  • driver/input_handler.h
  • driver/maccel.c
  • driver/params.h

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