Skip to content

Bump MSRV to 1.47, reduce size of sys::Events #40

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

Merged
merged 2 commits into from
Aug 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .clippy.toml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
msrv = "1.34"
msrv = "1.47"
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ jobs:
matrix:
# When updating this, the reminder to update the minimum supported
# Rust version in Cargo.toml and .clippy.toml.
rust: ['1.34']
rust: ['1.47']
steps:
- uses: actions/checkout@v3
- name: Install Rust
Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ name = "polling"
version = "2.3.0"
authors = ["Stjepan Glavina <stjepang@gmail.com>"]
edition = "2018"
rust-version = "1.34"
rust-version = "1.47"
description = "Portable interface to epoll, kqueue, event ports, and wepoll"
license = "Apache-2.0 OR MIT"
repository = "https://github.com/smol-rs/polling"
Expand Down
4 changes: 2 additions & 2 deletions src/epoll.rs
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ fn write_flags() -> libc::c_int {

/// A list of reported I/O events.
pub struct Events {
list: Box<[libc::epoll_event]>,
list: Box<[libc::epoll_event; 1024]>,
len: usize,
}

Expand All @@ -289,7 +289,7 @@ impl Events {
/// Creates an empty list.
pub fn new() -> Events {
let ev = libc::epoll_event { events: 0, u64: 0 };
let list = vec![ev; 1000].into_boxed_slice();
let list = Box::new([ev; 1024]);
Copy link
Collaborator Author

@taiki-e taiki-e Aug 21, 2022

Choose a reason for hiding this comment

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

I didn't do it on this patch, but calling alloc_zeroed via unsafe code is probably best from a point of view of performance.
https://godbolt.org/z/T1e8ETv61 https://godbolt.org/z/hcss6hEaT https://godbolt.org/z/fG9ddPsdq

let len = 0;
Events { list, len }
}
Expand Down
4 changes: 2 additions & 2 deletions src/kqueue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ impl Drop for Poller {

/// A list of reported I/O events.
pub struct Events {
list: Box<[libc::kevent]>,
list: Box<[libc::kevent; 1024]>,
len: usize,
}

Expand All @@ -221,7 +221,7 @@ impl Events {
data: 0,
udata: 0 as _,
};
let list = vec![ev; 1000].into_boxed_slice();
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I'm not sure why the old code used 1000 instead of 1024.

Copy link
Member

Choose a reason for hiding this comment

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

It would be a mis-optimization, if I had to guess.

let list = Box::new([ev; 1024]);
let len = 0;
Events { list, len }
}
Expand Down
4 changes: 2 additions & 2 deletions src/port.rs
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ fn write_flags() -> libc::c_short {

/// A list of reported I/O events.
pub struct Events {
list: Box<[libc::port_event]>,
list: Box<[libc::port_event; 1024]>,
len: usize,
}

Expand All @@ -195,7 +195,7 @@ impl Events {
portev_object: 0,
portev_user: 0 as _,
};
let list = vec![ev; 1000].into_boxed_slice();
let list = Box::new([ev; 1024]);
let len = 0;
Events { list, len }
}
Expand Down
8 changes: 3 additions & 5 deletions src/wepoll.rs
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ const WRITE_FLAGS: u32 = we::EPOLLOUT | we::EPOLLHUP | we::EPOLLERR;

/// A list of reported I/O events.
pub struct Events {
list: Box<[we::epoll_event]>,
list: Box<[we::epoll_event; 1024]>,
len: usize,
}

Expand All @@ -213,10 +213,8 @@ impl Events {
events: 0,
data: we::epoll_data { u64_: 0 },
};
Events {
list: vec![ev; 1000].into_boxed_slice(),
len: 0,
}
let list = Box::new([ev; 1024]);
Events { list, len: 0 }
}

/// Iterates over I/O events.
Expand Down